import pandas as pd
import json

# 加载 Excel 文件
file_path = './data_infos/question_data.xlsx'  # 替换为你的文件路径
sheet_name = 'Sheet1'  # 替换为你想读取的工作表名称，也可以是索引，比如 0

# 读取 Excel 表格
df = pd.read_excel(file_path, sheet_name=sheet_name)

data = []
# 遍历每一列并输出数据
for _, row in df.iterrows():
    id = row[0]
    index = row[1]
    question = row[2]
    options = row[3].split('，')
    item = {
        "id": index,
        "text": question,
        "options": options
    }
    data.append(item)

# 保存为 JSON 文件
output_file = './data_infos/output.json'  # 输出文件名
with open(output_file, 'w', encoding='utf-8') as f:
    json.dump(data, f, ensure_ascii=False, indent=4)


